<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function cached(fn){
            let obj = Object.create(null)
            return function(str){
                let hit = obj[str]
                return hit || (obj[str] =fn(str))
            }
        }

        //封装一个首字母大写的函数
        function uper(str){
            str = str.toLowerCase()
            return str.charAt(0).toUpperCase() + str.substring(1)
        }
        
        let cacheUp = cached(uper)
        console.log(cacheUp('ABC'))
    </script>
</body>
</html>